<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Menus extends Model
{
    use SoftDeletes;
    protected $table = 'menu';
    protected $fillable=[ 'parent_id', 'sort', 'title','icon','uri' ];


    public function manyRoles()
    {
        return $this->belongsToMany(Roles::class,'role_menu','menu_id','role_id');
    }

    //子分类
    public function childs()
    {
        return $this->hasMany(Menus::class,'parent_id','id');
    }
    //所有子类
    public function allChilds()
    {
        return $this->childs()->with('allChilds');
    }

}
